package cn.com.w.common.PublicHandler;

import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Component
public class PublicHandler {

    public static  <T> boolean saveOne(T t, IService<T> service) {
        return t != null && service.save(t);
    }

    public static  <T> boolean saveAll(List<T> list, IService<T> service) {
        if (CollectionUtils.isEmpty(list)) {
            return false;
        }
        return service.saveBatch(list);
    }
}
